﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

using ZFB.Common;
using ZFB.IServices;

namespace ZFB.WebAPI.Controllers
{
    /// <summary>
    /// 预约
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class HouseAppointmentsController : ControllerBase
    {
        private readonly IHouseAppointmentsServices houseAppointmentsServices;

        public HouseAppointmentsController(IHouseAppointmentsServices houseServices)
        {
            this.houseAppointmentsServices = houseServices;
        }
        /// <summary>
        /// 新增一个预约用户
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="name"></param>
        /// <param name="phoneNum"></param>
        /// <param name="houseId"></param>
        /// <param name="visitDate"></param>
        /// <returns></returns>
       [HttpPost]
       public async Task<ApiResult> AddNew(long? userId, string name, string phoneNum, long houseId, DateTime visitDate) 
        {
            return await houseAppointmentsServices.AddNewAsync(userId, name, phoneNum, houseId, visitDate);
        }
        /// <summary>
        /// 乐观锁解决并发
        /// </summary>
        /// <param name="adminUserId"></param>
        /// <param name="huoseAppointmentId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> Follow(long adminUserId, long huoseAppointmentId) 
        {
            return null;
        }
        /// <summary>
        /// 根据Id获取
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> GetById(long id) 
        {
            return await houseAppointmentsServices.GetByIdAsync(id);
        }
        /// <summary>
        /// 得到城市中状态status的预约数
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> GetToTalCount(long cityId, string status) 
        {
            return await houseAppointmentsServices.GetToTalCountAsync(cityId, status);
        }
        /// <summary>
        /// 分页获取
        /// </summary>
        /// <param name="cityId"></param>
        /// <param name="status"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult> GetPageDateAsync(long cityId, string status, int page, int limit) 
        {
            return await houseAppointmentsServices.GetPageDateAsync(cityId, status, page, limit);
        }
    }
}
